package com.chy.edu.controller.front;

import com.chy.commonutils.Result;
import com.chy.edu.pojo.EduCourse;
import com.chy.edu.pojo.EduTeacher;
import com.chy.edu.service.EduCourseService;
import com.chy.edu.service.EduTeacherService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("eduservice/indexfront")
@CrossOrigin
public class IndexFrontController {

    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduTeacherService teacherService;

    @ApiOperation(value = "查询前8条热门课程，查询前4条名师")
    @GetMapping("index")
    public Result index() {
        // 查询前8条热门课程
        List<EduCourse> courseList = courseService.listHotCourse();
        // 查询前4条名师
        List<EduTeacher> teacherList = teacherService.listHotTeacher();
        return Result.ok()
                .data("courseList",courseList)
                .data("teacherList",teacherList);
    }
}
